import React, {Component} from 'react';
import cs from 'classnames'
import BaseCmpt from '../BaseCmpt';
import './index.css';
import {Input, Button} from 'antd';

const {TextArea} = Input;

class MVideo extends BaseCmpt {

    static defaultProps = {
        data: {
            type: 5,
            style: {
                height: '240px'
            },
            dataset: {}
        }
    };

    constructor(props) {
        super(props);
    }

    render() {
        var {onSelected, selected, data} = this.props;
        var {style, dataset} = data;
        var url = dataset.url || '';
        var autoplay = dataset.autoplay || '0';
        var _url = dataset._url;

        try {
            url = decodeURIComponent(url);
        } catch (e) {
        }
        return (
            <div
                onClick={(e) => {
                    onSelected && onSelected(e)
                }}
                className={cs({'mVideo cmptEle': true, 'cmptEle_selected': selected})}
                style={style}
            >
                {
                    autoplay == 1 ?
                        <video src={_url} controls="controls" autoplay></video>
                        :
                        <video src={_url} controls="controls"></video>
                }
            </div>
        );
    }
}

export default MVideo;
